package com.ethan.luocj.elephant.activity;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;

import com.ethan.luocj.elephant.R;
import com.github.mikephil.charting.charts.LineChart;
import com.github.mikephil.charting.components.Description;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.LineData;
import com.github.mikephil.charting.data.LineDataSet;

import java.util.ArrayList;
import java.util.List;

public class LineActivity1 extends AppCompatActivity {

    private LineChart mChart;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_line1);
        mChart = findViewById(R.id.line_chart1);

        Description desc = new Description();
        desc.setText("haha");
        mChart.setDescription(desc);

        mChart.setTouchEnabled(false);
//        mChart.setDragEnabled(false);
        mChart.setScaleEnabled(false);
        mChart.setPinchZoom(false);
        mChart.setDoubleTapToZoomEnabled(false);

        List<Entry> entries = new ArrayList<Entry>();

        for (int i = 0; i < 10; i++) {
            entries.add(new Entry(i, (float) Math.random() * 10));
        }

        LineDataSet dataSet = new LineDataSet(entries, "Label"); // add entries to dataset

        LineData lineData = new LineData(dataSet);
        mChart.setData(lineData);
        mChart.invalidate(); // refresh

    }

}
